﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ScriptEditor.Commands
{
    class Command_CreateTextBox : Command
    {
        public string text
        {
            get
            {
                return Text;
            }
            set
            {
                Text = value;
            }
        }
        public string name
        {
            get
            {
                return Value1;
            }
            set
            {
                Value1 = value;
            }
        }
        public float duration
        {
            get
            {
                return float.TryParse(Value2, out float result) ? result : 0.5f;
            }
            set
            {
                Value2 = value.ToString();
            }
        }
        public float alpha
        {
            get
            {
                return float.TryParse(Value3, out float result) ? result : 1;
            }
            set
            {
                Value3 = value.ToString();
            }
        }
        public Vector3 position
        {
            get
            {
                return StringToVector3(Value4);
            }
            set
            {
                Value4 = Vector3ToString(value);
            }
        }
        public Vector2 size
        {
            get
            {
                return StringToVector2(Value5);
            }
            set
            {
                Value5 = Vector2ToString(value);
            }
        }
        public int fontSize
        {
            get
            {
                return int.TryParse(Value6, out int reslut) ? reslut : 1;
            }
            set
            {
                Value6 = value.ToString();
            }
        }
        public TextAlignmentOptions alignment
        {
            get
            {
                return Enum.TryParse(Value7, out TextAlignmentOptions result) ? result : TextAlignmentOptions.Left;
            }
            set
            {
                Value7 = value.ToString();
            }
        }
        public string textJp
        {
            get
            {
                return Value8;
            }
            set
            {
                Value8 = value;
            }
        }
        public string textTc
        {
            get
            {
                return Value9;
            }
            set
            {
                Value9 = value;
            }
        }
        public Command_CreateTextBox()
        {
            CommandType = COMMANDTYPE.CreateTextBox;
            text = "请输入文本";
            name = "请输入消息框名称";
            duration = 0.5f;
            alpha = 1;
            position = new Vector3 { x = 0, y = 0, z = 0 };
            size = new Vector2 { x = 3, y = 1 };
            fontSize = 1;
            alignment = TextAlignmentOptions.Left;
            textJp = "";
            textTc = "";
        }
        public Command_CreateTextBox(string Text, string Name, float Duration, float Alpha, Vector3 Position, Vector2 Size, int FontSize, TextAlignmentOptions Alignment, string TextJp = "", string TextTc = "")
        {
            CommandType = COMMANDTYPE.CreateTextBox;
            text = Text;
            name = Name;
            duration = Duration;
            alpha = Alpha;
            position = Position;
            size = Size;
            fontSize = FontSize;
            alignment = Alignment;
            textJp = TextJp;
            textTc = TextTc;
        }
        public override string ToString()
        {
            return CommandType.ToString() + ":\n" + "创建消息框:" + text;
        }
    }
}
